package com.noahedu.style.span;

import android.text.TextPaint;
import android.text.style.ClickableSpan;
import android.util.Log;
import android.view.View;

public class StrongURLSpan extends ClickableSpan {
	
	private static final String TAG = "StrongURLSpan";
	private boolean mUnderline;
	private boolean mUseDefaultColor;
	private int mColor;
	private String mUrl;
	
	public StrongURLSpan(String url) {
		this(url, true);
	}
	
	public StrongURLSpan(String url, boolean underline) {
		mUrl = url;
		mUseDefaultColor = true;
		mUnderline = underline;
	}
	
	public StrongURLSpan(String url, int color) {
		this(url, color, true);
	}

	public StrongURLSpan(String url, int color, boolean underline) {
		mUrl = url;
		mUseDefaultColor = false;
		mColor = color;
		mUnderline = underline;
	}

	@Override
	public void onClick(View widget) {
		Log.v(TAG, "onclick............");
	}
	
	// 这里改变了ClickableSpan的默认表现
	@Override
    public void updateDrawState(TextPaint ds) {
		if(mUseDefaultColor) {
	        ds.setColor(ds.linkColor);
		} else {
			ds.setColor(mColor);
		}
		
        ds.setUnderlineText(mUnderline);
    }
}
